<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>天天生鲜-用户中心</title>
	<link rel="stylesheet" type="text/css" href="css/reset.css">
	<link rel="stylesheet" type="text/css" href="css/main.css">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<script src="js/sweetalert.min.js"></script>
	<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
    <link href="css/sweetalert.css" rel="stylesheet">

</head>
<% 
	Object pre_global_info_user_name = request.getSession().getAttribute("account");
	String global_info_user_name = null == pre_global_info_user_name ? "" : pre_global_info_user_name.toString();
	request.getSession().setAttribute("pre-page", request.getServletPath());
%>
<body>
	<div class="header_con">
		<div class="header">
			<div class="welcome fl">欢迎来到饭否!</div>
			<div class="fr">
				<div class="login_info fl">
					欢迎您：<em><%= null == pre_global_info_user_name ? global_info_user_name : "请登录" %></em>
				</div>
				<% if(null == pre_global_info_user_name) { %>
				<div class="login_btn fl">
					<a href="/FAFCode/UserManagement/login.jsp">登录</a>
					<span>|</span>
					<a href="/FAFCode/UserManagement/register.jsp">注册</a>
				</div>
				<% } else { %>
				<div class="user_link fl">
					<a href="/FAFCode/UserManagement/user_center_info.jsp">用户中心</a>
					<span>|</span>
					<a href="/FAFCode/MyCart">我的购物车</a>
					<span>|</span>
					<a href="/FAFCode/UserManagement/user_center_order.jsp">我的订单</a>
				</div>
				<% } %>
			</div>
		</div>		
	</div>

	<div class="search_bar clearfix">
		<a href="/FAFCode/Index" class="logo fl"><img src="images/logo.png"></a>
		<div class="sub_page_name fl">|&nbsp;&nbsp;&nbsp;&nbsp;用户中心</div>
		<div class="search_con fr">
			<input type="text" class="input_text fl" name="" placeholder="搜索商品">
			<input type="button" class="input_btn fr" name="" value="搜索">
		</div>		
	</div>

	<div class="main_con clearfix">
		<div class="left_menu_con clearfix">
			<h3>用户中心</h3>
			<ul>
				<li><a href="user_center_info.jsp" >· 个人信息</a></li>
				<li><a href="user_center_order.jsp">· 全部订单</a></li>
				<li><a href="user_center_site.jsp">· 收货地址</a></li>
				<li><a href="user_center_update.jsp">· 个人信息修改</a></li>
				<li><a href="user_center_pwd.jsp" class="active">· 修改密码</a></li>
			</ul>
		</div>
		<div class="right_content clearfix">
			<div class="info_con clearfix">
				<h3><font face=微软雅黑  size=5 style="font-weight:100"><b>基本信息：</b></font></h3>
					<ul class="user_info_list2">
						<table align="left" width="400">
							<tr>
									<td width="120" height="20" align="right" style="font-weight:100">
										<font face=微软雅黑  size=3.5 >
											<b>
												原密码：
											</b>	
										</font>
									</td>
									
									<td>
									 <INPUT TYPE="password" SIZE="24" name="pwd" id="pwd" 
											onmouseover="this.style.borderColor='white';this.style.backgroundColor='lightblue'" 
											style="width: 106; height:25px;background:transparent;border:1px solid #f9f9f9" 
											onmouseout="this.style.borderColor='white';this.style.backgroundColor='#f9f9f9'" 
											style="border-width:1px;border-color=white">
									</td> 
							</tr>
							<tr>
									<td width="120" height="20" align="right" style="font-weight:100">
										<font face=微软雅黑  size=3.5 >
											<b>	
												新密码：
											</b>
										</font>
									</td>
									
									<td>
									 <INPUT TYPE="text" SIZE="24" name="newpwd" id="newpwd" 
											onmouseover="this.style.borderColor='white';this.style.backgroundColor='lightblue'" 
											style="width: 106; height:25px;background:transparent;border:1px solid #f9f9f9" 
											onmouseout="this.style.borderColor='white';this.style.backgroundColor='#f9f9f9'" 
											style="border-width:1px;border-color=white">
									</td>
						   </tr>	
						   <tr>	
									<td width="120" height="20" align="right" style="font-weight:100">
										<font face=微软雅黑  size=3.5 >
											<b>
												确认新密码：
											</b>
										</font>
									</td>
									
									<td>
									 <INPUT TYPE="text" SIZE="24" name="newcpwd" id="newcpwd" 
											onmouseover="this.style.borderColor='white';this.style.backgroundColor='lightblue'" 
											style="width: 106; height:25px;background:transparent;border:1px solid #f9f9f9" 
											onmouseout="this.style.borderColor='white';this.style.backgroundColor='#f9f9f9'" 
											style="border-width:1px;border-color=white">
									</td>
							</tr>
							<tr>
									<td align="center" colspan="2" >
										<br>
										<input type="submit" id="submit" value="确认修改" class="info_submit" onclick="submit()" style="margin-right:100px;">
										<input type="hidden" name="edit" id="edit" >
									</td>
							</tr>	
						</table>
					</ul>
			</div>
		</div>
	</div>
	<div class="footer">
		<div class="foot_link">
			<a href="#">关于我们</a>
			<span>|</span>
			<a href="#">联系我们</a>
			<span>|</span>
			<a href="#">招聘人才</a>
			<span>|</span>
			<a href="#">友情链接</a>		
		</div>
		<p>CopyRight © 2016 北京天天生鲜信息技术有限公司 All Rights Reserved</p>
		<p>电话：010-****888    京ICP备*******8号</p>
	</div>
	<script type="text/javascript">
	function submit(){
	var pwd =document.getElementById("pwd").value;
	var newpwd =document.getElementById("newpwd").value;
	var newcpwd =document.getElementById("newcpwd").value;
	$.ajax({
		   method:"post",
		   url:"${pageContext.request.contextPath}/UserUpdatePwd",
		   data:{password:pwd,newpwd:newpwd,newcpwd:newcpwd},
		   dataType: "json",
		   success: function(data){
				if(data.code==1){
					swal({
				        title: "成功",
				        text: "保存成功",
				        type: "success",
				        showConfirmButton: true
				        
				    });
				}
				if(data.code==-1){
					 swal({
		                    title: "错误",
		                    text: "和原密码不一致！",
		                    type: "warning",
		                    confirmButtonColor: "#DD6B55",
		                    closeOnConfirm: false
		                });
				}
				if(data.code==0){
					 swal({
		                    title: "错误",
		                    text: "两次新密码不一致！",
		                    type: "error",
		                    confirmButtonColor: "#ff0000",
		                    closeOnConfirm: false
		                });
				}
		   }
	  	});
	}
	</script>
</body>
</html>